#ifndef FILE_BADA_H_
#define FILE_BADA_H_

#include <stdint.h>
#include <FIo.h>
#include <FBase.h>
#include "FileInterface.h"

class BadaFile : public opennav::FileInterface {
public:
	BadaFile() { }

	result Construct(const Osp::Base::String& filePathName) {
		file_.Construct(filePathName, L"r");
		Osp::Io::FileAttributes attribute;
		file_.GetAttributes(filePathName, attribute);
		size_ = (int32_t)attribute.GetFileSize();
		return E_SUCCESS;
	}

public:
	bool seek(int32_t pos) {
		return file_.Seek(Osp::Io::FILESEEKPOSITION_BEGIN,(long int)pos) == E_SUCCESS;
	}

	bool read(void* buffer, int32_t size, int32_t& read_bytes) {
		read_bytes = (int32_t)file_.Read(buffer, (int)size);
		return true;
	}

	bool close() {
		return true;
	}

	bool size(int32_t& size) {
		size = this->size_;
		return true;
	}

	bool position(int32_t& position) {
		position = (int32_t)file_.Tell();
		return true;
	}

private:
	Osp::Io::File file_;
	int32_t size_;
};

#endif
